﻿using System;
using System.Web.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class SecurityPolicySectionManager : ConfigurationManagerBase
	{
		private SecurityPolicySection section;

		public SecurityPolicySectionManager()
		{
			this.section = (SecurityPolicySection)base.GetConfigurationSection("system.web/securityPolicy");
		}

		public void AddTrustLevel(string name, string policyFile)
		{
			this.section.TrustLevels.Add(new TrustLevel(name, policyFile));
			this.Save();
		}
		public void ModifyTrustLevel(string name, string policyFile)
		{
			this.section.TrustLevels[name].PolicyFile = policyFile;
			this.Save();
		}
		public void RemoveTrustLevel(string name)
		{
			TrustLevel trustLevel = this.section.TrustLevels[name];
			this.section.TrustLevels.Remove(trustLevel);
			this.Save();
		}
		public TrustLevel GetTrustLevel(string name)
		{
			return this.section.TrustLevels[name];
		}
		public TrustLevelCollection GetTrustLevelCollection()
		{
			return this.section.TrustLevels;
		}
	}
}
